package com.easy.venue.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easy.common.bean.VenueBean;
import com.easy.common.service.IVenueService;
import com.easy.venue.mapper.VenueMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@DubboService // dubbo服务
public class VenueService extends ServiceImpl<VenueMapper, VenueBean> implements IVenueService {
    @Override
    public VenueBean getVenueById(Integer id) {

        return super.getById(id);
    }

    @Override
    public Integer addVenue(VenueBean venueBean) {
        if(super.save(venueBean))
            return 1;
        else
            return 0;
    }

    @Override
    public Integer updateVenue(VenueBean venueBean) {
        return super.updateById(venueBean)?1:0;
    }

    @Override
    public Integer deleteVenue(Integer id) {
        return super.removeById(id)?1:0;
    }


    @Override
    public List<VenueBean> getAll(VenueBean venueBean) {
        LambdaQueryWrapper<VenueBean> queryWrapper = new LambdaQueryWrapper<>();
        return super.list(queryWrapper);
    }

    @Override
    public IPage<VenueBean> getPage(VenueBean venueBean, Page<VenueBean> page) {
        LambdaQueryWrapper<VenueBean> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(VenueBean::getId,venueBean.getId());
        return super.page(page);
    }
}
